package com.example.hxds.dr.service.impl;

import cn.hutool.core.map.MapUtil;
import cn.hutool.json.JSONUtil;
import com.example.hxds.dr.db.dao.DriverSettingsDao;
import com.example.hxds.dr.service.DriverSettingsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;

@Service
public class DriverSettingsServiceImpl implements DriverSettingsService {

    @Autowired
    DriverSettingsDao driverSettingsDao;
    @Override
    public HashMap searchDriverSettings(long driverId) {
        String settings = driverSettingsDao.searchDriverSettings(driverId);
        HashMap result = JSONUtil.parseObj(settings).toBean(HashMap.class);
        boolean bool = MapUtil.getInt(result, "listenService") == 1;
        result.replace("listenService",bool);
        bool = MapUtil.getInt(result, "autoAccept") == 1;
        result.replace("autoAccept",bool);
        return result;
    }
}
